// 导入vuex辅助函数
import { mapGetters } from "vuex";

export default {
  computed: {
    ...mapGetters("cart", ["getTotal"]),
  },

  watch: {
    getTotal() {
      this.setBadeg();
    },
  },
  onShow() {
    this.setBadeg();
  },
  methods: {
    setBadeg() {
      if (this.getTotal > 0) {
        uni.setTabBarBadge({
          index: 2,
          text: this.getTotal + "",
        });
      } else {
        uni.setTabBarBadge({
          index: 2,
        });
      }
    },
  },
};
